% BEM-LAP-MAT project
% Matlab/Freemat codes
% Copyright 2008 Stephen Kirkup 
% http://www.researchgate.net/profile/Stephen_Kirkup
% University of Central Lancashire
% Issued under the GNU General Public License 2007, see gpl.txt
% www.boundary-element-method.com
% contact: stephen@boundary-element-method.com
% http://www.researchgate.net/profile/Stephen_Kirkup


% function [L,M,Mt,N] =lbem2(n,vertpts,elemvert,p_on,needL,needM,needMt,needN)
% Sets up the matrices required in the boundary element method
%  for a boundary made up of n elements. vertpts lists the coordinates
%  of the edges of the elements and elemvert lists the pairs of vertices
%  that define each element.needL,needM,needMt,needN indicate which matrices
%  are needed by being set to true.


function [L,M,Mt,N] =lbem2_on(n,vertpts,elemvert,needL,needM,needMt,needN)

  [qa,qb]=vertices(n,vertpts,elemvert);

  p=(qa+qb)/2;
  
  qbma=qb-qa;
  
  for(i=1:n)
    qlen(i)=norm(qbma(i,:));
  end

  for (i=1:n)
    normp(i,1)=-qbma(i,2)/qlen(i);
    normp(i,2)=qbma(i,1)/qlen(i);
  end
   
  [L,M,Mt,N] =lbem2(n,p,normp,n,vertpts,elemvert,true,needL,needM,needMt,needN);
  

  